<?php

//<editor-fold defaultstate="collapsed" desc="License & Copyright">
/*
 * @license
 */

/**
 *
 * @author Jevgeni Geimanen (jevgeni.geimanen@gmail.com)
 */
//</editor-fold>
class JSPropertiesCollection {

    //<editor-fold defaultstate="collapsed" desc="Struct">
    /**
     * @var SCStruct IJSStruct 
     */
    private $_Struct = null;

    /**
     *
     * @return SCStruct IJSStruct
     */
    public function getStruct() {
        return $this->_Struct;
    }

    /**
     *
     * @param SCStruct IJSStruct $struct
     * @return JSPropertiesCollection 
     */
    public function setStruct(IJSStruct  &$struct) {
        assert(is_subclass_of($struct, 'SCStruct'));
        $this->_Struct = $struct;
        return $this;
    }

    //</editor-fold>

    /**
     *
     * @param JSPropertyCollection $collection 
     */
    private function CollectJSProperties(&$collection) {
        $collection['class'] = SCCoreHelper::getJSStructClassName($this->getStruct());
        $this->getStruct()->CollectJSProperties($collection);
        
    }

    /**
     *
     * @var array
     */
    private $_Properties;

    /**
     *
     * @return array
     */
    public final function getProperties() {
        if ($this->_Properties === null) {
            $this->_Properties = array();
            $this->CollectJSProperties($this->_Properties);
        }
        return $this->_Properties;
    }

}

?>
